/**
 * @Author: LTT 17386012013@163.com
 * @Date: 2024-08-16 15:26:39
 * @Description:
 * @LastEditTime: 2024-08-19 16:09:48
 * @LastEditors: LTT 17386012013@163.com
 */

import { SlateEditor, SlateNode, IDomEditor } from '@wangeditor/editor';

export const hasUndeletableNode = (editor: IDomEditor) => {
	const nodeEntries = SlateEditor.nodes(editor, {
		match: (node: any) => node,
		universal: true,
		mode: 'lowest'
	});
	return [...nodeEntries].some(([node]) => {
		return node?.undeletable;
	});
};

export const hasDavinciBlockNode = (editor: IDomEditor) => {
	const nodeEntries = SlateEditor.nodes(editor, {
		// @ts-ignore
		match: (node: SlateNode) => node,
		universal: true,
		mode: 'lowest'
	});
	return [...nodeEntries].some(([node]) => {
		// @ts-ignore
		return node?.type?.startsWith?.('davinci');
	});
};

